package com.ruoyi.appointment.controller;

import com.ruoyi.appointment.dto.ProcessDTO;
import com.ruoyi.appointment.service.CcsProcessService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 审核 Controller
 *
 * @author zzh
 * @date 2024-10-26
 */
@RestController
@RequestMapping("/process")
@Api(tags = "审核模块")
public class CcsProcessController extends BaseController {

    @Autowired
    private CcsProcessService ccsProcessService;

    @PostMapping
    @ApiOperation("新增审核")
    public AjaxResult addProcess(@RequestBody ProcessDTO processDTO) {
        return ccsProcessService.savaProcess(processDTO, getUserId());
    }

    @GetMapping
    @ApiOperation("查询目前所有审核列表")
    public AjaxResult listProcess() {
        try {
            Long userId = getUserId();
            return ccsProcessService.getProcess(userId);
        } catch (Exception e) {
            return error("资源服务，虽暂时开发；但仍需 token");
        }
    }

    @GetMapping("/{processId}")
    @ApiOperation("人工审核通过")
    public AjaxResult passProcess(@PathVariable Long processId) {
        return ccsProcessService.passProcess(processId);
    }

}
